package me.gijspennings.jumpandduck.graphics;

import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

public class SpriteSheet {
    
    public static SpriteSheet tiles = new SpriteSheet("/textures/tiles.png", 256, 256);
    public static SpriteSheet player = new SpriteSheet("/textures/player.png", 256, 256);
    
    private final int width, height;
    private final String path;
    public int[] pixels;
    
    private SpriteSheet(String path, int width, int height) {
        this.path = path;
        this.width = width;
        this.height = height;
        pixels = new int[width * height];
        load();
    }
    
    private void load() {
        try {
            BufferedImage image = ImageIO.read(SpriteSheet.class.getResource(path));
            image.getRGB(0, 0, width, height, pixels, 0, width);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    public int getWidth() {
        return width;
    }
    public int getHeight() {
        return height;
    }
    
}
